package com.example.mapper.controller;

import com.example.mapper.domain.Menu;
import com.example.mapper.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/menu")
public class Menucontroller {

    @Autowired
    private MenuService menuService;

    @GetMapping("")
    public JData getAll(){
        List<Menu> result = menuService.getAll();
        return new JData(0,"ok",result);
    }

    @GetMapping("/{id}")
    public JData getFindById(@PathVariable Integer id){
        Menu result = menuService.getById(id);
        return new JData(0,"ok",result);
    }
}
